import Field from 'winged/utils/wt-model-field'
import Code from '../utils/Code'
import times from '../../../Resources/utils/wt-time-utils'
export default {
	title:"评估表列表",
	name:'Service',
	tableName:'service_composes',
	query: {
		method: 'DRONE',
		url: 'evaluation/consulting/get_service_compose_list',
		transfer: true,
		pagination: true,
		// // 在修改的时候需要进行单条记录查询，用于获取关联麻醉记录
		// getOnEdit: true
		countParam:'total_num',
		sizeParam:'page_size',
		extraParams: ['order_status','doctor_user_id','search_key','bmi_grade'],
	},

	service_type:[
		{
			current_order_status:10
		},
		{
			current_order_status:11
		},
		{
			current_order_status:12
		},
		{
			current_order_status:13
		},
		{
			current_order_status:-11
		},
		{
			current_order_status:-12
		},
		{
			current_order_status:20
		},
		{
			current_order_status:21
		},
		{
			current_order_status:30
		},
		{
			current_order_status:31
		},
		{
			current_order_status:32
		},
	],
		bmi_grades:[
		"红色",
		"绿色",
		"黄色",
		"粉色",
		"未分组"
	],
	fields:[
		{
			label:"评估表编号",
			type:Field.types.text,
			display:true,
			name: 'current_order_id',
			tableName: 'current_order_id',
			minWidth:'130px',
	},{
			label:"患者姓名",
			type:Field.types.text,
			display:true,
			name:'patient_name',
			tableName: 'patient_name',
			minWidth:'100px',
			builder: function(data) {
				if (!data[this.tableName]) {
					let items = data.patient_info.name;
					data[this.tableName] = items;
				}
			},
		},{
			label:"会员等级",
			type:Field.types.text,
			display:true,
			name:'bmi_grade',
			tableName: 'bmi_grade',
			minWidth:'100px',
			customDisplayComponent: 'wt-patient-class',
			builder: function(data) {
				if (!data[this.tableName]) {
					let items = data.auto_evaluations;
					let item;
					for(let i = 0; i < items.length; i++){
						if(items[i].param_slug == "loose_weight_bmi_classify"){
							item = items[i].report;
							break;
						}
					}
					data[this.tableName] = item;
				}
			},
		},{
			label:"身份证号",
			type:Field.types.text,
			display:true,
			name:'patient_id_card',
			tableName: 'patient_id_card',
			minWidth:'180px',
			builder: function(data) {
				if (!data[this.tableName]) {
					let items = data.patient_info.idcard;
					data[this.tableName] = items;
				}
			},
		},{
			label:"联系方式",
			type:Field.types.text,
			display:true,
			name:'patient_phone',
			tableName: 'patient_phone',
			minWidth:'120px',
			builder: function(data) {
				if (!data[this.tableName]) {
					let items = data.patient_info.phone;
					data[this.tableName] = items;
				}
			},

		},{
			label:"订单状态",
			type:Field.types.text,
			display:true,
			name:'service_status',
			tableName: 'service_status',
			minWidth:'180px',
			builder:function (data) {
				data[this.tableName] = Code.parse(data).text
			}

		},{
			label:"创建时间",
			type:Field.types.text,
			display:true,
			name:'create_date',
			minWidth:'180px',
			tableName: 'create_date',
			builder:function(data){
				if(!!window.ActiveXObject || "ActiveXObject" in window){
					data[this.tableName] = data[this.tableName].replace(new RegExp(/-/gm),'/')
				}
				data[this.tableName] = times.format(data[this.tableName].substr(0,19))
			}
		},{
			label: '附件',
			type: Field.types.text,
			saveAsJson: true,
			display: true,
			summary: true,
			allowUpload:false,
			uploadByComponent: true,
			preSubmit: true,
			name: 'order_files_count',
			tableName: 'order_files_count',
			customDisplayComponent: 'wt-is-imgs',
		}
	]
}